$(document).ready(function(){
    $('.numeric').autoNumeric({aPad: false});

    $('.btn_active').live('click', function(){
        i = $(this);
        _id_key = i.attr('_id_key');
        _id_value = i.attr('_id_value');
        _field_key = i.attr('_field_key');
        _field_value = i.attr('_field_value');
        _table = i.attr('_table');
        $.post(
            ADMIN_URL+"/active",
            {id_key:_id_key, id_value:_id_value, field_key:_field_key, field_value:_field_value, table:_table},
            function(data){
                if (_field_value == '1') {
                    i.removeClass(i.attr('_icon_active'));
                    i.addClass(i.attr('_icon_unactive'));
                    i.attr('_field_value', '0');
                } else {
                    i.removeClass(i.attr('_icon_unactive'));
                    i.addClass(i.attr('_icon_active'));
                    i.attr('_field_value', '1');
                }
            }
        );
    });

    $('.redirect').live('click', function(){
        i = $(this);
        window.location.href=i.attr('_href');
    });
});


function ImgError(source){
    source.src = BASE_URL+"public/img/noimage.jpg";
    source.onerror = "";
    return true;
}
